const fs=require("fs");
const path=require("path")
async function demo() {
let  statPromise=new Promise((resolve,reject)=>{
    fs.stat("11",(err,data)=>{
        if (err){
            console.log(err);
            reject(err);
        }else {
            resolve(data);
        }
    })

})


let readdirPromise=new Promise((resolve, reject) => {
    fs.readdir("11",(err,files)=>{
        if (err){
            reject(err)
        }else {
            resolve(files)
        }
    })
})
    let stat=await statPromise;
    console.log(stat.isDirectory());
    if (stat.isDirectory()){
        let files=await readdirPromise;
        files.forEach(async (fileName)=>{
            let extname=path.extname(fileName);

            if (extname===".txt"){
                let statFile=await pStat(path.join(dirName,fileName));
            //    获取文件大小
                console.log(fileName + "  =  " + statFile.size)
            }
        })
    }
}
demo()